<template>
  <div class="expert-card" v-if="expert">
    <!-- 顶部标题 -->
    <!-- <div class="card-title">鱼病专家</div> -->

    <!-- 突出显示的长条部分 -->
    <div class="highlight-bar">
      <div class="name-title">
        <span class="expert-name">{{ expert.expertName }}</span>
        <span class="divider">|</span>
        <span class="expert-title">{{ expert.title }}</span>
      </div>
      <div class="expert-avatar" :style="avatarStyle"></div>
    </div>

    <!-- 详细描述部分 -->
    <div class="expert-desc">
      <div class="desc-title">擅长疾病：</div>
      <div class="desc-content">
        {{ expert.specialtyDisease || "暂无描述" }}
      </div>
      <!--      <div class="desc-title" style="margin-top:12px;">擅长品种：</div>-->
      <!--      <div class="desc-content">-->
      <!--        {{ expert.specialtyFish || '暂无描述' }}-->
      <!--      </div>-->
      <!--     -->
    </div>
  </div>
</template>

<script>
import { ref, onMounted, computed } from "vue";
import { mockFishDiseaseApi } from "@/api";

export default {
  name: "ExpertCard",
  setup() {
    const expert = ref(null);

    const fetchExpert = async () => {
      const res = await mockFishDiseaseApi.getExpertList();
      // 取第一个专家
      expert.value = res.data && res.data.length > 0 ? res.data[0] : null;
    };

    onMounted(() => {
      fetchExpert();
    });

    // 头像样式
    const avatarStyle = computed(() => {
      if (expert.value && expert.value.url) {
        return {
          backgroundImage: `url(${expert.value.url})`,
          backgroundSize: "cover",
          backgroundPosition: "center",
          backgroundColor: "#eee",
        };
      }
      return { backgroundColor: "#ddd" };
    });

    return {
      expert,
      avatarStyle,
    };
  },
};
</script>

<style scoped>
/* 卡片整体样式 */
.expert-card {
  width: 540px;
  max-width: 1000px;
  margin: 0 auto;
  font-family: "Microsoft YaHei", sans-serif;
  background-color: rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  position: relative;
  height: 340px;
}

/* 顶部标题 */
.card-title {
  padding: 18px 0;
  background-color: #0a1a3a;
  color: white;
  font-size: 22px;
  font-weight: bold;
  text-align: center;
}

/* 突出显示的长条部分 */
.highlight-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background-color: rgba(255, 255, 255, 0.05);
  margin: 0 15px;
  border-radius: 8px;
  position: relative;
  top: -10px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  top: 5px;
}

.name-title {
  display: flex;
  align-items: center;
  color: whitesmoke;
  font-size: 18px;
}

.expert-name {
  font-weight: bold;
}

.divider {
  margin: 0 10px;
  color: whitesmoke;
}

.expert-title {
  color: whitesmoke;
}

.expert-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background-color: #ddd;
  border: 3px solid white;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  /* 动态背景图由js控制 */
}

/* 详细描述部分 */
.expert-desc {
  padding: 25px 20px 20px;
  color: whitesmoke;
  margin-top: -5px;
}

.desc-title {
  font-weight: bold;
  margin-bottom: 12px;
  font-size: 16px;
}

.desc-content {
  line-height: 1.6;
  font-size: 15px;
  text-align: justify;
}
</style>
